<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<%@include file="/WEB-INF/common/common.jsp" %>
<%@include file="/WEB-INF/common/header.jsp" %>
<%--<script>
    var resizeImg = function(img, maxWidth, maxHeight){
        var w = img.width,
            h = img.height;

        // 当图片比预览区域小时不做任何改变
        if(w < maxWidth && h < maxHeight) return;

        // 当实际图片比例大于预览区域宽高比例时
        // 缩放图片宽度，反之缩放图片宽度
        w/h > maxWidth/maxHeight  ? img.width = maxWidth : img.height = maxHeight;
</script>--%>
<script>
    function good(id) {
        $.get("${ctx}/updateGood", {"id": id}, function (data) {
            if (data.success) {
                var a = $('#' + id).html();
                $('#' + id).html(parseInt(a) + 1);
                alert(data.msg);
            } else {
                alert(data.msg);
            }
        });
    }
    $(function () {

    });
</script>
<style>
    img {
        object-fit: cover;
        width: 100%;
    }
</style>
<div class="container">
    <div class="row" style="height: 1000px">
        <div class="col-md-2">
            <div class="h4">全国院校</div>
            <div class="h5">
                <ul class="list-group ">
                    <c:forEach items="${requestScope.lists}" var="school1">
                        <c:forEach items="${school1}" var="school">
                            <c:choose>
                                <c:when test="${school.parentId == 0}">
                                    <li class="list-group-item active">${school.name}</li>
                                </c:when>
                                <c:otherwise>
                                    <a href="${ctx}/index?school=${school.name}">
                                        <li class="list-group-item text-center">${school.name}</li>
                                    </a>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </c:forEach>
                </ul>
            </div>
        </div>
        <div class="col-md-10">
            <div>
                <form class="form-group" method="get" id="form">
                    <input type="hidden" name="school" value="${requestScope.data.school}">
                    <input type="hidden" value="${requestScope.page.pageNum}" name="pageNum" id="pageNum">
                    <div class="col-md-3"><select class="form-control" name="platform">
                        <option value="">下拉选择平台</option>
                        <c:forEach items="${requestScope.platforms}" var="platform">
                            <c:choose>
                                <c:when test="${platform.name eq requestScope.data.platform}">
                                    <option selected value="${platform.name}">${platform.name}</option>
                                </c:when>
                                <c:otherwise>
                                    <option value="${platform.name}">${platform.name}</option>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </select></div>
                    <div class="col-md-3"><select class="form-control" name="department">
                        <option value="">下拉选择部门</option>
                        <c:forEach items="${requestScope.departments}" var="department">
                            <c:choose>
                                <c:when test="${department.name eq requestScope.data.department}">
                                    <option selected value="${department.name}">${department.name}</option>
                                </c:when>
                                <c:otherwise>
                                    <option value="${department.name}">${department.name}</option>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </select></div>
                    <div class="col-md-3"><input type="date" value="${requestScope.data.time}" name="time"
                                                 placeholder="时间" class="form-control"></div>
                    <div class="col-md-3"><input class="btn btn-success" type="submit" value="查询"></div>
                </form>
            </div>
            <br><br><br>
            <div class="row">
                <div class="h3 text-chenter">${re}</div>
                <c:forEach items="${requestScope.datas}" var="data">
                    <div class="col-md-3" style="height: 340px;float: left;padding: 1px">
                        <div class="text-center" style="width: 202px">
                            <a href="showDetail?id=${data.id}">
                                <div style="height: 220px;width:202px;border: solid #cccccc 1px; vertical-align: bottom">
                                    <span style="color: #2aabd2">♡</span>
                                    <span id="${data.id}" style="color: #2aabd2">${data.good}</span>
                                    <div style="width: 200px;height: 220px">
                                        <img src="${ctx}/static/image/${data.photo}" width="200" height="200"
                                             style="line-height: 200px">
                                    </div>
                                </div>
                            </a>
                            <div class="h5">文案：${data.title}</div>
                            <div class="h6">标签：${data.tap} 大图：${data.size}</div>
                            <div class="h6">上传时间：${data.time} ${data.school}</div>
                            <div class="h6 ">
                                <a href="#" onclick="good(${data.id})" class="btn-sm btn-primary">点赞</a>
                                <a href="showDetail?id=${data.id}" class="btn-sm btn-primary">查看</a>
                                <a href="${ctx}/download?id=${data.id}" class="btn-sm btn-primary">下载</a>
                            </div>
                        </div>
                    </div>
                </c:forEach>
            </div>
            <script>

            </script>
            <c:set var="num" value="${requestScope.page.pageNum}"></c:set>
            <div class="row">
                <div class="col-md-4"></div>
                <div class="col-md-4">
                    <%@include file="/WEB-INF/common/page.jsp" %>
                </div>
                <div class="col-md-4"></div>
            </div>
        </div>
    </div>
</div>
<%@include file="/WEB-INF/common/bottom.jsp" %>